package cn.xuchunh.campusbbs.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.support.v4.view.ViewCompat;

import cn.xuchunh.campusbbs.R;
import cn.xuchunh.campusbbs.bean.Forum;
import cn.xuchunh.campusbbs.ui.fragments.ForumFragment;
import cn.xuchunh.campusbbs.utils.IntentParamsKey;

/**
 * Created by XuChunH on 2015/9/12.
 */
public class ForumActivity extends FragmentContainerActivity<ForumFragment> {

    private Forum forum;

    public static void launch(Context context, Forum forum) {
        Intent intent = new Intent(context, ForumActivity.class);
        intent.putExtra(IntentParamsKey.FORUM, forum);
        context.startActivity(intent);
    }

    @Override
    protected ForumFragment getFrament() {
        return ForumFragment.getInstance(forum);
    }

    @Override
    protected int containerId() {
        return R.id.container;
    }

    @Override
    protected int createContentRes() {
        return R.layout.layout_simple_container;
    }

    @Override
    protected void beforeInitView() {
        forum = getIntent().getParcelableExtra(IntentParamsKey.FORUM);
        if (forum == null) {
            finish();
            return;
        }

        setTitle(forum.getName());
        setShowHomeUp(true);
    }

    @Override
    protected void afterInitView() {
        ViewCompat.setElevation(getToolbar(), 0);
    }
}
